//
//  ChangePasswordViewController.swift
//  PaiYiChuan
//
//  Created by 刘申臣 on 2017/10/27.
//  Copyright © 2017年 刘申臣. All rights reserved.
//

import UIKit

class ChangePasswordViewController: UIViewController,UITableViewDelegate,UITableViewDataSource {

    @IBOutlet weak var changePasswordTable: UITableView!
    
    let titleArry : [String] = ["旧密码：","新密码：","确认密码："]
    let hintArry : [String] = ["请输入旧密码","请输入新密码","请再次输入新密码"]
    
    
    // MARK: - TableViewDataSource
    
    @available(iOS 2.0, *)
    func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
        return 10
    }

//    func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
//        let footerView = UIView()
//        footerView.backgroundColor = UIColor.groupTableViewBackground
//        let footerLabel = UILabel()
//        footerLabel.text = "密码为6-12位数字与字母"
//        footerLabel.textColor = UIColor.darkGray
//        footerLabel.sizeToFit()
//        footerLabel.frame = footerView.frame
//        footerView.addSubview(footerLabel)
//        return footerView
//        
//    }
    func tableView(_ tableView: UITableView, titleForFooterInSection section: Int) -> String? {
        return "   密码为6-12位数字与字母"
    }
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
         let  cell = self.changePasswordTable.dequeueReusableCell(withIdentifier: "changePasswordCell", for: indexPath) as! ChangePasswordTableViewCell
        cell.titleLabel.text = self.titleArry[indexPath.row]
        cell.inputField.placeholder = self.hintArry[indexPath.row]
        return cell
        
    }
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return titleArry.count
    }

    override func viewDidLoad() {
        super.viewDidLoad()

        createNavBar()
        self.changePasswordTable.delegate = self
        self.changePasswordTable.dataSource = self
        let cellNib = UINib.init(nibName: "ChangePasswordTableViewCell", bundle: nil)
        self.changePasswordTable.register(cellNib, forCellReuseIdentifier: "changePasswordCell")
        self.title = "修改密码"
        

        // Do any additional setup after loading the view.
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    
    
    
    //MARK: - 创建右上角导航按钮
    func createNavBar(){
        
        let completeBtn = UIBarButtonItem.init(title: "完成", style: .done, target: self, action: #selector(completeChanged))
        self.navigationItem.setRightBarButton(completeBtn, animated: true)
    }
    
    func completeChanged()  {
        print("点击完成")
    }

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
